/* eslint-disable */
import { createRouter, createWebHashHistory } from "vue-router";

//  页面
import mapLayout from "@/mapLayout"
import toolBar from "@/views/toolBar/toolBar"
import layerControl from "@/views/layerControl/layerControl"
import detailInfo from "@/components/DetailInfo/detailInfo"
import queryInfo from "@/components/QueryInfo/queryInfo"

const routes = [
    // 地图
    {
        path: "/",
        redirect: "/map",
        component: mapLayout,
        //  children中路由对象的path值不需要斜杠'/'，components必须带s
        children: [
            // 地图
            {
                path: "/map",
                name: "map",
                components: {
                    default: mapLayout,
                    layerControl,
                    toolBar
                },
            },
            // 详细信息
            {
                path: "/map/detailInfo",
                name: "detailInfo",
                components: {
                    default: mapLayout,
                    detailInfo,
                    toolBar,
                    layerControl,
                }
            },
            // 信息列表
            {
                path: "/map/queryInfo",
                name: "queryInfo",
                components: {
                    default: mapLayout,
                    queryInfo,
                    toolBar,
                    layerControl,
                }
            }
        ]
    },
];

const router = createRouter({
    history: createWebHashHistory(),
    routes
});

window.historyStack = [];

router.beforeEach((to, from, next) => {
    window.historyStack.push(from); // 保存离开的路由
    next();
});

export default router